#pragma once
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/System/Clock.hpp>
#include <string>

class Animation
{
public:
	Animation(){}
	Animation(std::string spritesheetpath, unsigned int frames_count, float delay, bool looping = true);
	~Animation();
	
	void play() {if(!m_playing){m_playing = true;m_timer.restart();}}
	void stop() {m_playing = false;m_currentframe = 0;}
	void pause(){m_playing = false;}

	bool isPlaying() const {return m_playing;}

	void update();
	void draw();

	sf::Sprite & sprite(){return m_spritesheet;}

	unsigned int size();
private:
	unsigned int m_framescount;
	unsigned int m_currentframe;
	sf::Clock m_timer;
	sf::Sprite m_spritesheet;
	float m_delay;
	bool m_loop;
	bool m_playing;
};

